package cn.autowired.exam.service.impl;

import cn.autowired.exam.entity.Application;
import cn.autowired.exam.dao.ApplicationMapper;
import cn.autowired.exam.service.ApplicationService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cq
 * @since 2018-05-25
 */
@Service
public class ApplicationServiceImpl extends ServiceImpl<ApplicationMapper, Application> implements ApplicationService {

    @Override
    public List<Application> selectByTeacherId(Integer teacherId) {
        List<Application> applications = baseMapper.selectList(new EntityWrapper<Application>().eq(Application.Field.teacherId, teacherId));
        return applications;
    }

    @Override
    public List<Application> selectByTeacherIdAndDate(Integer teacherId, String date) {
        List<Application> applications = baseMapper.selectList(new EntityWrapper<Application>()
                .eq(Application.Field.teacherId, teacherId)
                .like(Application.Field.time, date));

        return applications;
    }

    @Override
    public List<Application> selectByStudentNo(String studentNo) {
        List<Application> applications = baseMapper.selectList(new EntityWrapper<Application>()
                .eq(Application.Field.studentNo, studentNo));

        return applications;
    }

    @Override
    public List<Application> selectByStudentNoAndDate(String studentNo, String date) {
        List<Application> applications = baseMapper.selectList(new EntityWrapper<Application>()
                .eq(Application.Field.studentNo, studentNo)
                .like(Application.Field.time, date));
        return applications;
    }


    @Override
    public List<Application> selectByStudentNoAndTeacherId(String studentNo, Integer teacherId) {
        List<Application> applications = baseMapper.selectList(new EntityWrapper<Application>()
                .eq(Application.Field.studentNo, studentNo)
        .eq(Application.Field.teacherId,teacherId));
        return applications;
    }
}
